package com.wust.demo1.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class EncrypMD5 {
	public static String eccrypt(String info) throws NoSuchAlgorithmException{
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		byte[] srcBytes = info.getBytes();
		md5.update(srcBytes);
		byte[] resultBytes = md5.digest();
		return new String(resultBytes);
	}
	
	public static void main(String args[]) throws NoSuchAlgorithmException{
		System.out.println("你好 eclipse!");
		String msg = "hello world";
		String resultBytes = EncrypMD5.eccrypt(msg);
		System.out.println("after md5"+new String(resultBytes));
		System.out.println("before md5"+msg);
		System.out.println("The end");
		
	}
}
